package com.cpj.bsyyzx.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cpj.bsyyzx.entity.Register;
import com.cpj.bsyyzx.entity.User;
import com.cpj.bsyyzx.mapper.UserMapper;
import com.cpj.bsyyzx.service.IUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
//import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 五个臭皮匠
 * @since 2021-04-27
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {


    @Override
    public Page pageList(Page page, User user) {
        if(page == null){
            page = new Page();
        }

        QueryWrapper<User> wrapper = new QueryWrapper<>();

        if(StringUtils.isNotBlank(user.getUserName())) {
            wrapper.like("name",user.getUserName());
        }

        // 如果分页返回 IPage 如果不分页 返回 List
        return super.page(page,wrapper);
    }

    @Override
    public IPage<User> selectPageVo(Page<User> page, Wrapper<User> wrapper) {
        User user=new User();
        QueryWrapper<User> wrapper1 = new QueryWrapper<>();
        if(StringUtils.isNotBlank(user.getUserName())) {
            wrapper1.like("name",user.getUserName());
        }

        return getBaseMapper().selectPageVo(page,wrapper);
    }

    @Override
    public boolean batchdel(Integer[] ids) {
        return false;
    }


}
